package com.loctek.importexport.data;

import android.os.Parcel;
import android.os.Parcelable;



/**
 * Created by timfei on 16/7/12.
 */
public class ImageItem implements Parcelable {

    public String name;       //图片的名字

    public String path;       //图片的路径

    public long size;         //图片的大小

    public int width;         //图片的宽度

    public int height;        //图片的高度

    public String mimeType;   //图片的类型

    public long addTime;      //图片的创建时间

    public int type;          //0为图片,1为视频

    /**
     * 图片的路径和创建时间相同就认为是同一张图片
     */
    @Override
    public boolean equals(Object o) {
        try {
            ImageItem other = (ImageItem) o;
            return this.path.equalsIgnoreCase(other.path) && this.addTime == other.addTime;
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
        return super.equals(o);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(name);
        parcel.writeString(path);
        parcel.writeLong(size);
        parcel.writeInt(width);
        parcel.writeInt(height);
        parcel.writeString(mimeType);
        parcel.writeLong(addTime);
        parcel.writeInt(type);

    }


    public static final Parcelable.Creator<ImageItem> CREATOR = new Parcelable.Creator<ImageItem>() {

        @Override
        public ImageItem createFromParcel(Parcel parcel) {

            ImageItem imageItem = new ImageItem();
            imageItem.name = parcel.readString();
            imageItem.path = parcel.readString();
            imageItem.size = parcel.readLong();
            imageItem.width = parcel.readInt();
            imageItem.height = parcel.readInt();
            imageItem.mimeType = parcel.readString();
            imageItem.addTime = parcel.readLong();
            imageItem.type = parcel.readInt();

            return imageItem;
        }

        @Override
        public ImageItem[] newArray(int i) {
            return new ImageItem[0];
        }
    };
}
